﻿using AiXiu.BLL;
using AiXiu.IBLL;
using AiXiu.Model;
using System;
using System.Web.UI;

namespace AiXiu.WebSite
{
    /// <summary>
    /// 视频播放页
    /// </summary>
    public partial class Play : Page
    {
        public string VideoId;
        public int UserId;
        public TBVideos Video;
        public TBUsers Author;
        public GetPlayInfoResult playInfo;
        public bool IsLike = false;
        public long LikeCount = 0;
        public long DiscussCount = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                this.VideoId = Request.QueryString["id"];
                TBUsers user = IdentityManager.ReadUser();
                this.UserId = user.Id;
                // 获取发布者信息
                IVideoManager videoManager = new VideoManager();
                this.Video = videoManager.GetVideoByVideoId(VideoId);
                this.Author = Video.TBUsers;
                // 获取播放地址
                this.playInfo = videoManager.InitPlay(VideoId);


                // 点赞
                ILikeManager likeManager = new LikeManager();
                this.IsLike = likeManager.IsLike(VideoId, UserId);
                this.LikeCount = likeManager.Count(VideoId);

                //评论
                IDiscussManager discussManager = new DiscussManager();
                this.DiscussCount = discussManager.Count(VideoId);

            }
        }
    }
}